<include file="../Public/_header" />
<div class="so_main">
  <!-------- 节点列表 -------->
  <div class="page_tit">节点列表</div>
  <div class="Toolbar_inbox">
  	<div class="page right">{$html}</div>
	<a href="{:U('admin/User/addNode')}" class="btn_a"><span>添加节点</span></a>
	<a href="javascript:void(0);" class="btn_a" onclick="deleteNode();"><span>删除节点</span></a>
  </div>
  <div class="list">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th style="width:30px;">
		<input type="checkbox" id="checkbox_handle" onclick="checkAll(this)" value="0">
    	<label for="checkbox"></label>
	</th>
    <!--<th class="line_l">ID</th>-->
    <th class="line_l">应用名</th>
    <th class="line_l">模块名</th>
    <th class="line_l">方法名</th>
    <th class="line_l">关联方法</th>
    <th class="line_l">说明</th>
    <th class="line_l">操作</th>
  </tr>
  <volist id="vo" name="data">
	  <tr overstyle='on' id="node_{$vo['node_id']}">
	    <td><input type="checkbox" name="checkbox" id="checkbox2" onclick="checkon(this)" value="{$vo.node_id}"></td>
	    <!--<td>{$vo.id}</td>-->
	    <td>{$vo.app_name}<br />{$vo.app_alias}</td>
		<td>{$vo.mod_name}<br />{$vo.mod_alias}</td>
	    <td>{$vo.act_name}<br />{$vo.act_alias}</td>
	    <td>
	        <php>if(empty($vo['sub_node'])){</php>无关联方法<php>}</php>
	    	<volist id="vo2" name="vo['sub_node']">
	    		{$vo2.act_name}<br />
	    	</volist>
	    </td>
	    <td>{$vo.description}<php>if(empty($vo['description'])){</php>无<php>}</php></td>
	    <td>
			<a href="{:U('admin/User/editNode', array('nid'=>$vo['node_id']))}">编辑</a> 
	    	<a href="javascript:void(0);" onclick="deleteNode({$vo['node_id']});">删除</a>
		</td>
	  </tr>
  </volist>
  </table>

  </div>
  <div class="list_btm">选择：<a href="javascript:void(0)">全部</a> - <a href="#">反选</a> - <a href="#">不选</a></div>
  <div class="Toolbar_inbox">
	<div class="page right">{$html}</div>
    <a href="{:U('admin/User/addNode')}" class="btn_a"><span>添加节点</span></a>
	<a href="javascript:void(0);" class="btn_a" onclick="deleteNode();"><span>删除节点</span></a>
  </div>
</div>

<script>
	//鼠标移动表格效果
	$(document).ready(function(){
		$("tr[overstyle='on']").hover(
		  function () {
		    $(this).addClass("bg_hover");
		  },
		  function () {
		    $(this).removeClass("bg_hover");
		  }
		);
	});
	
	function checkon(o){
		if( o.checked == true ){
			$(o).parents('tr').addClass('bg_on') ;
		}else{
			$(o).parents('tr').removeClass('bg_on') ;
		}
	}
	
	function checkAll(o){
		if( o.checked == true ){
			$('input[name="checkbox"]').attr('checked','true');
			$('tr[overstyle="on"]').addClass("bg_on");
		}else{
			$('input[name="checkbox"]').removeAttr('checked');
			$('tr[overstyle="on"]').removeClass("bg_on");
		}
	}

	//获取已选择的ID数组
	function getChecked() {
		var ids = new Array();
		$.each($('table input:checked'), function(i, n){
			ids.push( $(n).val() );
		});
		return ids;
	}

	//删除节点
	function deleteNode(ids) {
		ids = ids ? ids : getChecked();
		ids = ids.toString();
		if(ids == '' || !confirm('删除成功后将无法恢复，确认继续？')) return false;
		
		$.post("{:U('admin/User/doDeleteNode')}", {ids:ids}, function(res){
			if(res == '1') {
				ids = ids.split(',');
				for(i = 0; i < ids.length; i++) {
					$('#node_'+ids[i]).remove();
				}
				ui.success('保存成功');
			}else {
				ui.error('保存失败');
			}
		});
	}
	
	//搜索用户
	var isSearchHidden = <neq name="type" value="searchUser">1<else/>0</neq>;
	function searchUser() {
		if(isSearchHidden == 1) {
			$("#searchUser_div").slideDown("fast");
			$(".searchUser_action").html("搜索完毕");
			isSearchHidden = 0;
		}else {
			$("#searchUser_div").slideUp("fast");
			$(".searchUser_action").html("搜索用户");
			isSearchHidden = 1;
		}
	}
</script>

<include file="../Public/_footer" />